<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="__TEMPLATE__/webfile/css/main.css">
    <link rel="stylesheet" type="text/css" href="__TEMPLATE__/webfile/css/common.css" />
    <link rel="stylesheet" type="text/css" href="__TEMPLATE__/webfile/css/dai.css" />
    <link rel="stylesheet" href="__TEMPLATE__/webfile/css/bootstrap.min.css">
</head>
<script src="__TEMPLATE__/webfile/js/jquery.js"></script>
<script src="__TEMPLATE__/webfile/js/bootstrap.min.js"></script>
<body>
<div class="main usercenter w">
    <div class="user_gamerecord w">
       <div class="user_right right " style="width: 100%">
            <div class="user_main">
                <div class="tabbable"> <!-- Only required for left/right tabs -->
                    <ul class="nav nav-tabs" style="padding-top: 5px;padding-left: 5px;height: 40px">
                        <li class="active"><a href="#tab1" data-toggle="tab" class="badge badge-inversee" style="height: 23px">下线会员</a></li>
                        <li><a href="{:url('agent/branchAgent')}" class="badge badge-inversee" style="height: 23px">下线代理</a></li>
                        <li><a href="#tab3" data-toggle="tab" class="badge badge-inversee" style="height: 23px">添加代理</a></li>
                        <li><a href="#tab4" data-toggle="tab" class="badge badge-inversee" style="height: 23px">添加会员</a></li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active" id="tab1">
                            <!--下线会员　　-->
                            <div class="user_body ">
                                <div class="info_select">

                                </div>
                                <div class="buyrecord_data w90 boxs"  >
                                    <table class="table">
                                        <thead style="width: 100%;" >
                                        
                                        <tr>
                                            <th>
                                                ID
                                            </th>
                                            <th>
                                                账号
                                            </th>
                                            <th>
                                                投注时间
                                            </th>
                                            <th>
                                                投注金额
                                            </th>
                                            <th>
                                                投注号码
                                            </th>
                                            <th>
                                                投注彩种
                                            </th>
                                        </tr>
                                        {if condition="$count gt 0"}
                                        {foreach $touzhulist as $rt}
                                        <tr style=" background: white;">
                                            <th>
                                               {$rt.id}
                                            </th>
                                            <th>
                                               {$rt.username}
                                            </th>
                                            <th>
                                                {$rt.tz_time}
                                            </th>
                                            <th>
                                               {$rt.tzje}
                                            </th>
                                            <th>
                                               {$rt.tzhm}
                                            </th>
                                            <th>
                                                {$rt.cp_name_new}
                                            </th>
                                        </tr>
                                        {/foreach}
                                        {/if}
                                        </thead>
                                        {if condition="$count eq 0"}
                                        <tbody>
                                        <tr>
                                            <td colspan="10" class="no_border">
                                                <div class="empty_data">
                                                    暂无记录
                                                </div>
                                            </td>
                                        </tr>
                                        </tbody>
                                        {/if}
                                    </table>
                                    <!--页码-->
                                    <div style="width:98%; height:35px; line-height:35px; margin:auto; border-bottom:#CCCCCC dashed 1px; font-weight:700; color:#339933">

                                        <div style="width:450px; margin:auto">

                                            <div style="color:rgba(0,0,0,0.5);width:250px; text-align:center; float:left">共{$count}条记录，{$zys}页，当前第{$page}页</div>

                                            <div style="width:80px; text-align:center; float:left"><a href="{:url('agent/dai')}?ctouzhu_id={$ctouzhu_id}&page={$page-1}" style="color:rgba(0,0,0,0.9) " >上一页</a></div>

                                            <div style="width:80px; text-align:center; float:left"><a href="{:url('agent/dai')}?ctouzhu_id={$ctouzhu_id}&page={$page+1}" style="color:rgba(0,0,0,0.9) " >下一页</a></div>

                                        </div>

                                    </div>
                                </div>
                            </div>
                        </div>
                       
                        <div class="tab-pane" id="tab3">
                            <!--添加代理-->
                            <div class="user_body ">
                                <form class="form-horizontal" style="margin-top: 50px">
                                    <div class="control-group">
                                        <label class="control-label" for="zhanghao">代理账号</label>
                                        <div class="controls">
                                            <input type="text" id="zhanghao" placeholder="账号" name="zhanghao">
                                        </div>
                                        <div class="alert" style="position: absolute;top:115px;left:410px;margin: auto;height: 13px;line-height: 13px">
                                            <strong>Warning!</strong><span></span>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="inputPassword">登录密码</label>
                                        <div class="controls">
                                            <input type="password" id="inputPassword" placeholder="登录密码" name="password">
                                        </div>
                                        <div class="alert" style="position: absolute;top:165px;left:410px;margin: auto;height: 13px;line-height: 13px">
                                            <strong>Warning!</strong> <span></span>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="inputPassword2">重复密码</label>
                                        <div class="controls">
                                            <input type="password" id="inputPassword2" placeholder="重复密码">
                                        </div>
                                        <div class="alert" style="position: absolute;top:215px;left:410px;margin: auto;height: 13px;line-height: 13px">
                                            <strong>Warning!</strong> <span></span>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="return0">下线返点</label>
                                        <div class="controls">
                                            <input type="text" id="return0" placeholder="下线返点" name="return0">
                                        </div>
                                        <div class="alert" style="position: absolute;top:265px;left:410px;margin: auto;height: 13px;line-height: 13px">
                                            <strong>Warning!</strong><span></span>
                                        </div>
                                    </div>

                                    <div class="control-group">
                                        <div class="st1" name="agent" id="agent-under">
                                            <span style="float: left;margin-left:100px">是否可以发展下级代理</span>
                                            <label class="radio" style="float: left;margin-left: 30px">
                                                <input type="radio" name="optionsRadios" id="optionsRadios1" value="1" checked>
                                                是
                                            </label>
                                            <label class="radio" style="float: left;margin-left: 30px">
                                                <input type="radio" name="optionsRadios" id="optionsRadios2" value="0" >
                                                否
                                            </label>
                                        </div>
                                    </div>

                                    <div class="control-group">
                                        <!--提交提示-->
                                        <div class="alert alert-success pos" id="pos1">
                                            <strong>提交成功！</strong>
                                        </div>
                                        <div class="alert alert-infos pos" id="pos2">
                                            <strong>提交失败！</strong>
                                        </div>
                                    </div>

                                    <div class="control-group">
                                        <div style="margin-left: 100px;color: #C09853;margin-top: -10px">备注说明：</br>下线的返点不能高于或者等于本身的返点！</div>
                                        <div  style="height: 30px;margin-top: 20px;width: 100px;margin-left:220px; box-shadow:0 0 10px rgba(0,0,0,0.4);text-align:center;border-radius: 5px;background: #F4F4F4;line-height:30px;" id="submit">
                                            确定
                                        </div>
                                    </div>
                                </form>

                            </div>
                        </div>
                        <div class="tab-pane" id="tab4">
                            <!--添加会员-->
                            <div class="user_body ">
                                <form class="form-horizontal" style="margin-top: 50px">
                                    <div class="control-group st1">
                                        <label class="control-label" for="zhanghao2">会员账号</label>
                                        <div class="controls">
                                            <input type="text" id="zhanghao2" placeholder="会员账号">
                                        </div>
                                        <div class="alert" style="position: absolute;top:0;left:410px;margin: auto;height: 13px;line-height: 13px">
                                            <strong>Warning!</strong><span></span>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="inputPassword3">登录密码</label>
                                        <div class="controls">
                                            <input type="password" id="inputPassword3" placeholder="登录密码">
                                        </div>
                                        <div class="alert" style="position: absolute;top:165px;left:410px;margin: auto;height: 13px;line-height: 13px">
                                            <strong>Warning!</strong> <span></span>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="inputPassword4">重复密码</label>
                                        <div class="controls">
                                            <input type="password" id="inputPassword4" placeholder="重复密码">
                                        </div>
                                        <div class="alert" style="position: absolute;top:215px;left:410px;margin: auto;height: 13px;line-height: 13px">
                                            <strong>Warning!</strong><span></span>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <!--提交提示-->
                                        <div class="alert alert-success pos" id="pos3">
                                            <strong>提交成功！</strong>
                                        </div>
                                        <div class="alert alert-infos pos" id="pos4">
                                            <strong>提交失败！</strong>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <div style="margin-left: 100px;color: #C09853;margin-top: -10px">备注说明：</br>下线的返点不能高于或者等于本身的返点！</div>
                                        <div  style="height: 30px;margin-top: 20px;width: 100px;margin-left:220px; box-shadow:0 0 10px rgba(0,0,0,0.4);text-align:center;border-radius: 5px;background: #F4F4F4;line-height:30px;" id="submit2">
                                            确定
                                        </div>
                                    </div>
                                </form>


                            </div>
                        </div>
                    </div>
                </div>

            </div>
       </div>
    </div>
</div>
</body>
<script>
    $(document).ready(function(){
        var zhanghao=false;
        var zhanghao2=false;
        var password=false;
        var password2=false;
        var repassword=false;
        var repassword2=false;
        var return0=false;

//代理账号校验
        $("#zhanghao").blur(function() {
//            console.log($(this).val())
//            console.log($(this).parent().siblings('.alert').get(0))
//            $(this).parent().siblings('.alert').children('span').get(0).innerText='111'
            $("#pos1").css({'display':'none'});
            $("#pos2").css({'display':'none'});
            var reg = new RegExp("[\\u4E00-\\u9FFF]+","g");
            zhanghao=false;
            if($(this).val().trim()===''){
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='账号不能为空！';
            }else if(reg.test($(this).val())){
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='账号不能为汉字';
            }else if($(this).val().length<=5||$(this).val().length>=15){
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='账号长度在5-15之间';
            }
            else{
                zhanghao=true;
                $(this).parent().siblings('.alert').css({'display':'none'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText=''
            }
        });
//会员账号校验
        $("#zhanghao2").blur(function() {
            $("#pos3").css({'display':'none'});
            $("#pos4").css({'display':'none'});
            var reg = new RegExp("[\\u4E00-\\u9FFF]+","g");
            zhanghao2=false;
            if($(this).val().trim()===''){
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='账号不能为空！';
            }else if(reg.test($(this).val())){
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='账号不能为汉字';
            }else if($(this).val().length<=5||$(this).val().length>=15){
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='账号长度在5-15之间';
            }
            else{
                zhanghao2=true;
                $(this).parent().siblings('.alert').css({'display':'none'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText=''
            }
        });


//密码校验(1)
        $("#inputPassword").blur(function() {
            $("#pos1").css({'display':'none'});
            $("#pos2").css({'display':'none'});
            var reg = new RegExp("[\\u4E00-\\u9FFF]+","g");
            var reg2= new RegExp("^[a-z]");
            password=false;
            if($(this).val().trim()===''){
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='密码不能为空！'
            }else if(!reg2.test($(this).val())){
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='密码请以字母开头';
            }else if(reg.test($(this).val())){
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='密码不能为汉字';
            }else if($(this).val().length<=5||$(this).val().length>=20){
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='密码长度在5-20之间';
            }else{
                password=true;
                $(this).parent().siblings('.alert').css({'display':'none'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText=''
            }
        });
//密码校验(3)
        $("#inputPassword3").blur(function() {
            $("#pos3").css({'display':'none'});
            $("#pos4").css({'display':'none'});
            var reg = new RegExp("[\\u4E00-\\u9FFF]+","g");
            var reg2= new RegExp("^[a-z]");
            password2=false;
            if($(this).val().trim()===''){
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='密码不能为空！'
            }else if(!reg2.test($(this).val())){
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='密码请以字母开头';
            }else if(reg.test($(this).val())){
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='密码不能为汉字';
            }else if($(this).val().length<=5||$(this).val().length>=20){
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='密码长度在5-20之间';
            }else{
                password2=true;
                $(this).parent().siblings('.alert').css({'display':'none'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText=''
            }
        });


//重复密码校验(2)
        $("#inputPassword2").blur(function() {
            $("#pos1").css({'display':'none'});
            $("#pos2").css({'display':'none'});
            repassword=false;
            if($(this).val().trim()===''){
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='密码不能为空！'
            }else if($(this).val()!=$('#inputPassword').val()){
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='密码不一致';
            }
            else{
                repassword=true;
                $(this).parent().siblings('.alert').css({'display':'none'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText=''
            }
        });
//重复密码校验(4)
        $("#inputPassword4").blur(function() {
            $("#pos3").css({'display':'none'});
            $("#pos4").css({'display':'none'});
            repassword2=false;
            if($(this).val().trim()===''){
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='密码不能为空！'
            }else if($(this).val()!=$('#inputPassword3').val()){
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='密码不一致';
            }
            else{
                repassword2=true;
                $(this).parent().siblings('.alert').css({'display':'none'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText=''
            }
        });
//下线返点校验
        $("#return0").blur(function() {
            $('#pos1').css({'display':'none'});
            $('#pos2').css({'display':'none'});
            if($(this).val().trim()===''){
                return0=false;
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='下线返点不能为空！'
            }else if(isNaN($(this).val())){
                return0=false;
                $(this).parent().siblings('.alert').css({'display':'block'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText='下线返点必须是数字';
            }
            else{
                return0=true;
                $(this).parent().siblings('.alert').css({'display':'none'})
                $(this).parent().siblings('.alert').children('span').get(0).innerText=''
            }

        });



//添加代理信息提交
        $('#submit').eq(0).click(function(){
            if(zhanghao===true&&password===true&&repassword===true&&return0===true){
                //获取是否有下级代理
                var dd='';
                function agentUnder(){
                    $("#agent-under input").each(function (index,value) {
                        if(value.checked==true){
                            dd=$(this).val();
                        }
                    })
                    return dd
                }
// 拼接传送数据格式
                var aa= {"zhanghao1":$("#zhanghao").val(),"password1":$("#inputPassword").val(),"return0":$("#return0").val(),"agentUnder": agentUnder()}
                $.ajax({
                    url:"{:url('agent/addAgent')}?tj=yes",
                    type:"POST",
                    data:aa,
                    success: function(data) {
                        if(data=="ok"){
                            $('#pos1').css({'display':'block'});
                        }else{
                            $('#pos2').css({'display':'block'});
                        }
                    }
                });

            }else{
                $('#pos2').css({'display':'block'});
            }
        })
//添加会员信息提交
        $('#submit2').eq(0).click(function(){
            if(zhanghao2===true&&password2===true&&repassword2===true){
// 拼接传送数据格式
                var aa= {"zhanghao2":$("#zhanghao2").val(),"password2":$("#inputPassword3").val()}
                $.ajax({
                    url:"{:url('agent/addMember')}?tj=yes",
                    type:"POST",
                    data:aa,
                    success: function(data) {
                        if(data=="ok"){
                            $('#pos3').css({'display':'block'});
                        }else{
                            $('#pos4').css({'display':'block'});
                        }
                    }
                });
               
            }else{
                $('#pos4').css({'display':'block'});
            }
        })



    })
</script>
</html>